<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="<c:url value="/resources/js/reportes.js" />" type="text/javascript"></script>
<style type="text/css">
	.lista-botones,
	#formConsultaVentas,
	.tablaEstaciones{
		margin-left:40px !important;
	}
	
	#formConsultaVentas{
		margin-bottom:10px !important;
	}
	
	.mensaje-error{
		background:url("<c:url value='/resources/img/msg-error.png' />") repeat-x scroll 0 0 #F9C9C9;
		border:1px solid #F3ABAB;
		color:#8D0D0D;
		font-size:13px;
		padding:8px 10px 0;
		-moz-border-radius:5px;
		-webkit-border-radius:5px;
		border-radius:5px;
		height:26px;
		width:240px;
		text-align:center;
		margin-top:5px !important;
	}

	.texto-error{
		background:url("<c:url value='/resources/img/cross_octagon.png' />") left no-repeat;
		padding-left:30px;
	}
</style>
<title>::Consulta de Ventas:</title>
</head>
<body>
<form:form id="formConsultaVentas" action="consultaVentas.php" method="post">
		<input type="hidden" name="accion" value="consultar" />
		<table border = "0">
				<tr>
						<td class="celda" align="right">Estaci&oacute;n :</td>
						<td class="celda" class="celda" align="left">
						<select name="estacion">
							<c:forEach items="${listaEstaciones}" var="estacion">
								<option value="<c:out value="${estacion.idEstacion}" />"
								<c:if test="${idEstacion==estacion.idEstacion}">
									<c:out value=" selected='selected'" />
								</c:if>
								><c:out value="${estacion.codEstacion} - ${estacion.nombreEstacion}" /></option>
							</c:forEach>
						</select>
						</td>
				</tr>
				<tr>
						<td class="celda" align="right">Fecha :</td>
						<td class="celda" align="left">
						<c:if test="${fecha==null}"><input id="fecha" type="text" name="fecha" size="20" value="" /></c:if>
						<c:if test="${fecha!=null}"><input id="fecha" type="text" name="fecha" size="20" value="<c:out value="${fecha}" />" /></c:if>
						</td>
				</tr>
				<tr>
						<td>&nbsp;</td>
						<td align="left">
						<a href="javascript:document.forms['formConsultaVentas'].submit()" class="btn-registrar">Consultar</a>
						</td>
				</tr>
		</table>		
</form:form>
<c:if test="${resumen!=null}">
	<table cellspacing="0" class="tablaEstaciones">
		<caption>
		 	<div class="tituloTabla">Consulta de Ventas</div>
		 	<div class="botoneraTabla">
			 	<a href="generarReporte.php?id=<c:out value="${idEstacion}" />&amp;fecha=<c:out value="${fecha}" />" target="_blank">
			 		<img src="<c:url value="/resources/img/pdf.png" />" />
			 	</a>
		 	</div>
		 	<div style="clear:both"></div>
		</caption>
		<thead>
		<tr>
			<th class="cabecera-tabla" width="120" align="center">Nbr. Document</th>
			<th class="cabecera-tabla" align="center">Comprador</th>
			<th class="cabecera-tabla" width="100" align="center">Total Pen.(s/:)</th>
		</tr>
		</thead>
		<tbody>
			<c:forEach items="${ventas}" var="venta" varStatus="status">
					<c:if test="${status.index%2==0}">
					  <c:set var="estiloFila" value="fila-tabla-par" />
					</c:if>
					<c:if test="${status.index%2!=0}">
					  <c:set var="estiloFila" value="fila-tabla-impar" />
					</c:if>
					<tr class="<c:out value="${estiloFila}" />">
						   <td class="celda" align="center">
						   		<c:out value="${venta.nbrDocument}" />
						   </td>
						   <td class="celda" align="center">
							    <c:if test="${venta.custName!=''}">
							    	<c:out value="${venta.custName}" />
							    </c:if>  
							    <c:if test="${venta.custName==''}">
							   	    <c:out value="--No hay nombre--" />
							    </c:if>			    
						   </td>
						   <td class="celda" align="center">
						   		<c:out value="${venta.totalPen}" />   
						   </td>
					</tr>
			</c:forEach>
			<tr class="fila-final">
				<td class="celda">&nbsp;</td>
				<td class="celda" align="right">Total :&nbsp;</td>
				<td class="celda" align="center"><c:out value="${totalVentas}" /></td>
			</tr>
		</tbody>
	</table>
</c:if>
</body>
</html>
		